package com.itheima.service.impl;

import com.itheima.dao.NodeDao;
import com.itheima.po.Node;
import com.itheima.po.NodeAndUser;
import com.itheima.service.NodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class NodeServiceImpl implements NodeService {

    @Autowired
    NodeDao nodeDao;
    //创建笔记
    public void createNode(Node node){
        System.out.println("创建的笔记：" + node);
        nodeDao.createNode(node);
    }
    //搜索笔记
    public List<NodeAndUser> findNode(NodeAndUser node){
        System.out.println("搜索的笔记："+node);
        List<NodeAndUser> nodes = nodeDao.findNode(node);
        System.out.println(nodes);
        return nodeDao.findNode(node);
    }
    //通过用户名查找笔记
    public List<NodeAndUser> findNodeByUsername(NodeAndUser node){
        return nodeDao.findNodeByUsername(node);
    }
    //通过笔记id删除笔记
    public void deleteNodeByNodeId(NodeAndUser nodeAndUser){
        nodeDao.deleteNodeByNodeId(nodeAndUser.getNode_id());
    }
    //通过笔记id查找笔记
    public NodeAndUser findNodeByNodeId(int id){
        return nodeDao.findNodeByNodeId(id);
    }
    //通过笔记id修改笔记属性
    public void alterNodeByNodeId(NodeAndUser nodeAndUser){
        nodeDao.alterNodeByNodeId(nodeAndUser);
    }
    //通过笔记名查找一个笔记
    public NodeAndUser fingNodeByNodename(NodeAndUser nodeAndUser){ return nodeDao.fingNodeByNodename(nodeAndUser); }
    //通过笔记id为笔记的人气加1
    public void NodePopularityAdd1(int id){ nodeDao.NodePopularityAdd1(id); }
}
